package KnightsTour.GUI;

import KnightsTour.Square;
import java.awt.*;
import javax.swing.*;
/**
 *
 * @author Scott Robinson
 */
public class SquarePanel extends JPanel {

    private boolean visited;
    private int orderVisited;
    private final static int PREF_SIZE = 70;
    private final Square s;

    public SquarePanel (Color c, int preferedSize, Square s) {
        this.s = s;
        setBackground(c);
        setSize(preferedSize, preferedSize);
        setBorder(BorderFactory.createLineBorder(Color.BLACK));
        setLayout(new BorderLayout());
    }

    public SquarePanel (Color c, Square s) {
        this (c, PREF_SIZE, s);
    }

    public SquarePanel ( Square s) {
        this (Color.WHITE, PREF_SIZE, s);
    }

    public boolean wasVisited () {
        return visited;
    }

    public void setOrderVisited () {
        orderVisited = s.getOrderVisited();
        visited = true;
        JLabel label = new JLabel(Integer.toString(orderVisited), JLabel.CENTER);
        label.setFont(new Font (Font.SANS_SERIF,Font.BOLD,30));
        label.setForeground(Color.BLACK);
        add(label,BorderLayout.CENTER);
        validate();
    }

    public int getOrderVisited () {
        return orderVisited;
    }

    public Square getSquare () {
        return s;
    }
}
